package common

import (
	"context"
	"mini-app/internal/app/grpc/client"
	"mini-app/internal/app/grpc/protoc/devicec"

	"192.168.1.75/go-pkg/errorx"
	"192.168.1.75/go-pkg/logx"
)

// DeviceList 获取设备列表
func (GRPC) DeviceList(
	ctx context.Context,
	provinceID, cityID, districtID, locationID string,
	merchantID string,
	saleStatus int,
	robotID string,
	page, limit int,
) (*devicec.DeviceListRsp, error) {
	cli, err := client.GetAdminClient()
	if cli != nil && err == nil {
		rsp, err := cli.DeviceList(ctx, &devicec.DeviceListReq{
			MerchantId: merchantID,
			ProvinceId: provinceID,
			CityId:     cityID,
			DistrictId: districtID,
			LocationId: locationID,
			SaleStatus: int32(saleStatus),
			RobotId:    robotID,
			Page:       int64(page),
			Limit:      int64(limit),
		})
		if rsp != nil && err == nil {
			return rsp, err
		}
	} else {
		logx.Error(context.Background(), "GetDeviceAdminClient err")
		return nil, errorx.New("GetDeviceAdminClient er")
	}
	return nil, nil
}
